{% macro render(ViewAttr, SubNav) %}
  {% for Section, Links in SubNav %}
    {% set listClasses = ['NavList'] %}
    {% set listClasses = (
      listClasses.push('NavList--isCurrent') if ViewAttr.parent == Section, listClasses
    ) %}

    <ul class="{{ listClasses | join(' ') | trim }}">
      <li class="NavItem">
        <span class="NavHeading">{{ Section }}</span>
      </li>

      {% for Link in Links %}
        {% set linkHref = Link | lower | replace(' ', '-') %}
        {% set linkClasses = ['NavLink'] %}
        {% set linkClasses = (
          linkClasses.push('NavLink--isCurrent') if ViewAttr.child == Link, linkClasses
        ) %}
        {% set linkClasses = linkClasses | join(' ') | trim %}

        {% if '~' in Link %}
          {% set openingTag = '<span class="' + linkClasses + '">' %}
          {% set closingTag = '</span>' %}
        {% else %}
          {% set openingTag = '<a href="' + linkHref + '.html" class="' + linkClasses + '" title="See example: ' + Link + '">' %}
          {% set closingTag = '</a>' %}
        {% endif %}

        <li class="NavItem">
          {{ openingTag | safe }}
            {{ Link | replace('~', '') }}
          {{ closingTag | safe }}
        </li>
      {% endfor %}
    </ul>
  {% endfor %}
{% endmacro %}
